package com.ls.common.baseClass.mongodb;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: xiaosu
 * @date: 2018-09-20  20:59
 */
@Data
@ApiModel(parent = AbstractAuditingEntity.class)
public class MongoBaseObject extends AbstractAuditingEntity {

    @Id
    @ApiModelProperty(value = "ID")
    protected String    id;

    @ApiModelProperty(value = "关键字信息")
    protected String                    keyword;

    @ApiModelProperty(value = "扩展信息")
    protected Map<String, Serializable> extinfo = new HashMap<>();

    /**
     * 用户返回对象的额外信息封装
     */
    @Transient
    protected Map<String, Object>       links   = new HashMap<>();

    /**
     * 把对象的信息放置进去
     * @param key
     * @param value
     * @return
     */
    public MongoBaseObject link(String key, Object value) {
        links.put(key, value);
        return this;
    }

}
